package com.ymm.web.controller;

import com.ymm.platform.api.constants.dto.DriverShowDTO;
import com.ymm.platform.api.constants.dto.QueryDriverDTO;
import com.ymm.platform.api.constants.entity.DriverEntity;
import com.ymm.platform.api.facade.PlatformQueryDriverService;
import com.ymm.platform.api.facade.PlatformQueryOrderService;
import com.ymm.platform.api.utils.Result;
import com.ymm.platform.api.utils.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @Author: Xuecheng Li
 * @CreateTime: 2022-08-09 17:35
 * @Version: 1.0.0
 */
@CrossOrigin
@RestController
@Slf4j
@RequestMapping("/platform/driver")
public class DriverController {

    @Reference
    private PlatformQueryDriverService platformQueryDriverService;

    /**
    * @Author: chencong
    * @Description: 分页获取所有司机
    * @DateTime: 14:27 2022/8/16
    * @Params: [pageNum, pageSize]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriver")
    public Result queryAllDriver(Integer pageNum,Integer pageSize) {
        return platformQueryDriverService.queryAllDriver(pageNum,pageSize);
    }

    /**
    * @Author: chencong
    * @Description: 分页获取有效司机
    * @DateTime: 14:28 2022/8/16
    * @Params: [pageNum, pageSize]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverOnV")
    public Result queryDriverOnValid(Integer pageNum,Integer pageSize){
        return platformQueryDriverService.queryDriverOnValid(pageNum,pageSize);
    }

    /**
    * @Author: chencong
    * @Description: 按照 司机姓名，身份证和手机号码查询司机
    * @DateTime: 14:29 2022/8/16
    * @Params: [pageNum, pageSize, queryDriverDTO]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverOnC")
    public Result queryDriverOnCondition(Integer pageNum, Integer pageSize, QueryDriverDTO queryDriverDTO){
        log.info(queryDriverDTO.getDriverName());
        try{
            return platformQueryDriverService.queryDriverOnCondition(pageNum,pageSize,queryDriverDTO);
        }catch (Exception e){
            return Result.fail("信息不对");
        }

    }

    /**
    * @Author: chencong
    * @Description: 计算某个司机的总收入
    * @DateTime: 14:29 2022/8/16
    * @Params: [driverId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverIncome")
    public Result queryDriverTotalIncome(Long driverId) {
        return platformQueryDriverService.queryDriverTotalIncome(driverId);
    }

    /**
    * @Author: chencong
    * @Description: 获取某个司机的完单数目
    * @DateTime: 14:30 2022/8/16
    * @Params: [driverId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverCompleteOrder")
    public Result queryDriverCompleteOrder(Long driverId) {
        return platformQueryDriverService.queryDriverCompleteOrder(driverId);
    }

    /**
    * @Author: chencong
    * @Description: 获取某个司机的完单列表
    * @DateTime: 14:30 2022/8/16
    * @Params: [pageNum, pageSize, driverId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverCompleteOrderList")
    public Result queryDriverCompleteOrderList(Integer pageNum,Integer pageSize,Long driverId) {
        return platformQueryDriverService.queryDriverCompleteOrderList(pageNum,pageSize,driverId);
    }

    /**
    * @Author: chencong
    * @Description: 获取某个司机的未完单数目
    * @DateTime: 14:30 2022/8/16
    * @Params: [driverId]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverUncompleteOrder")
    public Result queryDriverUncompleteOrder(Long driverId) {
        return platformQueryDriverService.queryDriverUncompleteOrder(driverId);
    }

    /**
     * @Author: chencong
     * @Description: 获取某个司机的未完单列表
     * @DateTime: 14:30 2022/8/16
     * @Params: [driverId]
     * @Return com.ymm.platform.api.utils.Result
     */
    @RequestMapping("/getDriverUnCompleteOrderList")
    public Result queryDriverUnCompleteOrderList(Integer pageNum,Integer pageSize,Long driverId) {
        return platformQueryDriverService.queryDriverUncompleteOrderList(pageNum,pageSize,driverId);
    }

    /**
    * @Author: chencong
    * @Description: 通过司机姓名查询司机
    * @DateTime: 19:54 2022/8/18
    * @Params: [pageNum, pageSize, driverName]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverByName")
    public Result queryDriverListByName(Integer pageNum,Integer pageSize,String driverName) {

        return platformQueryDriverService.queryDriverListByName(pageNum,pageSize,driverName);
    }
    
    /**
    * @Author: chencong
    * @Description: 通过司机电话查询司机
    * @DateTime: 19:54 2022/8/18
    * @Params: [pageNum, pageSize, driverPhone]
    * @Return com.ymm.platform.api.utils.Result
    */
    @RequestMapping("/getDriverByPhone")
    public Result queryDriverListByPhone(Integer pageNum,Integer pageSize,String driverPhone) {
        return platformQueryDriverService.queryDriverListByPhone(pageNum,pageSize,driverPhone);
    }

}
